package com.qf.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Arrays;
import java.util.Date;

/**
 * @author 汤奇
 * @version V1.0
 * @Project BookPro
 * @Package com.qf.pojo
 * @Description:
 * @Date 2022/6/7 23:05
 */
public class User {
    //json转换的时候忽略这个字段
//    @JsonIgnore
    //阿里fastjson注解:忽略属性
    @JSONField(serialize = false)
    private Integer id;
    private String name;
    //json创的时候,给key改名字
//    @JsonProperty("sex")
    //阿里fastjson注解: 更改属性名称
    @JSONField(name = "sex")
    private Boolean gender;
//    @DateTimeFormat(pattern = "yyyy-MM-dd")
    //json转换的时候日期格式化
//    @JsonFormat(pattern = "yyyy-MM-dd")
    //阿里fastjson注解: 日期格式化
    @JSONField(format = "yyyy-MM-dd")
    private Date birthday;
    //如果这个字段的值为null, 那么不参与json转换, 自动忽略掉
//    @JsonInclude(JsonInclude.Include.NON_NULL)

    private String[] hobby;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getGender() {
        return gender;
    }

    public void setGender(Boolean gender) {
        this.gender = gender;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String[] getHobby() {
        return hobby;
    }

    public void setHobby(String[] hobby) {
        this.hobby = hobby;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", gender=" + gender +
                ", birthday=" + birthday +
                ", hobby=" + Arrays.toString(hobby) +
                '}';
    }
}
